package com.ysd.Controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ysd.Service.StudentService;
import com.ysd.entity.Student;
import com.ysd.util.ResultInfoUtil;

@CrossOrigin
@RestController
@RequestMapping("/Student")
public class StudentController { 
	@Autowired
	private StudentService studentservice;
	@GetMapping
	public ResultInfoUtil findAllUsers(Integer limit,Integer page,Student u) {
		Pageable pageable = PageRequest.of(page-1, limit);//PageRequest.of
		Page<Student> use =  studentservice.findAllStudent(u, pageable);
		return new ResultInfoUtil().success(use.getContent(),use.getTotalElements());
	}
}
